<template>
	<view class="serch-box">
		<view>
			<u-icon name="close" @click="goback"></u-icon>
		</view>
		<view>
			<u-search placeholder="请输入搜索的关键字" v-model="kw" @custom="search"></u-search>
		</view>
	</view>
</template>

<script>
	export default {
		name:"custom-nav-search",
		data(){
			return{
				kw:''
			}
		},
		watch:{
			keyword:{
				handler(newval){
					this.kw=newval
				}
			}
		},
		props:{
			keyword:{
				type:String
			}
		},
		methods:{
			search(){
				const rectList=JSON.parse(uni.getStorageSync("rectList")||'[]') 
				const isExits=rectList.includes(this.kw)
				if(!isExits){
					rectList.push(this.kw)
				}
				uni.setStorageSync("rectList",JSON.stringify(rectList))
				uni.navigateTo({
					url:'/pages/productlist/productlist?keyword='+this.kw
				})
			},
			goback(){
				uni.navigateBack()
			}
		}
	}
</script>

<style lang="scss">
	.serch-box{
		width:750rpx;
		height: 100rpx;
		background-color: yellow;
		@include flex-box(start,center,row)
	}
</style>